<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Questions extends Model
{
    protected $table = "questions"; //指定表
    protected $primaryKey = "id"; //指定id字段
    public $timestamps = false; //关闭时间自动

    // 关联答案
    public function answers(){
    	return $this->hasMany('App\Model\Answers','qid','id');
    }

    // 获取正确答案
    public function success(){
    	return $this->hasMany('App\Model\Answers','qid','id')->where('is_success',1);
    }
}
